<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>修改所有a的target</title>
		<script>
			function dian(){
				var b=document.getElementsByTagName("a");
				for(var i=0;i<b.length;i++){
					b[i].target="_blank";
				}
			}
		</script>
	</head>
	<body >
		<a href="https://www.taobao.com">taobao</a><br />
		<a href="https://www.yhd.com">一号店</a>
		<div>
			<a href="https://www.jd.com">jd</a>
		</div>
		<p>
			<a href="http://www.bdqn.cn">zongbu</a>
		</p>
		<input type="button" value="修改所有a的target" onclick="dian();"/>
	</body>
	 
</html>
